package com.quartet.modules.statistics.controller;


import com.quartet.api.ApiResult;
import com.quartet.api.PageResult;
import com.quartet.modules.service.dto.TServiceClickCountResponseDto;
import com.quartet.modules.service.dto.TServiceInfoResponseDto;
import com.quartet.modules.service.service.TServiceInfoService;
import com.quartet.modules.statistics.dto.ServiceStatisticsRequestDto;
import com.quartet.modules.statistics.dto.ServiceStatisticsResponseDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 服务统计信息表
 *
 * @author makejava
 * @since 2021-06-20 18:55:07
 */
@RestController
@RequestMapping("tServiceStatistics")
@Slf4j
@Api(tags = "业务：服务统计")
public class TServiceStatisticsController {

    /**
     * 服务对象
     */
    @Resource
    private TServiceInfoService tServiceInfoService;

    /**
     * 按时间分组查询服务统计信息
     * @return 查询结果
     */
    @ApiOperation("按时间分组查询服务统计信息")
    @PostMapping("/queryServiceStatisticsData")
//    @AuthKeyValidated(value = "statisticalAnalysis")
    public ApiResult<List<ServiceStatisticsResponseDto>> queryServiceStatisticsData(@RequestBody ServiceStatisticsRequestDto serviceStatisticsRequestDto) {
        List<ServiceStatisticsResponseDto> serviceStatisticsResponseDtoList = tServiceInfoService.queryServiceStatisticsData(serviceStatisticsRequestDto);
        return ApiResult.ok(serviceStatisticsResponseDtoList);
    }

    /**
     * 分页查询服务统计信息
     * @return 查询结果
     */
    @ApiOperation("分页查询服务统计信息")
    @PostMapping("/queryServiceStatisticsList")
//    @AuthKeyValidated(value = "statisticalAnalysis")
    public ApiResult<PageResult<TServiceClickCountResponseDto>> queryServiceStatisticsList(@RequestBody ServiceStatisticsRequestDto serviceStatisticsRequestDto) {
        PageResult<TServiceClickCountResponseDto> pageResult = tServiceInfoService.queryServiceStatisticsList(serviceStatisticsRequestDto);
        return ApiResult.ok(pageResult);
    }


}
